[all:vars]
{% if ssh_port is defined %}
ansible_port={{ ssh_port }}
{% endif %}

{% if automation_hub|bool %}
[automation_hub]
{%   for host in hostvars %}
{%     if "automation-hub" in host %}
{{ host|replace(ec2_name_prefix + "-", "") }} ansible_host={{ hostvars[host].ansible_host }} ansible_port=22 ansible_user=ec2-user ansible_ssh_private_key_file="{{ playbook_dir }}/{{ ec2_name_prefix }}/{{ ec2_name_prefix }}-private.pem"
{%     endif %}
{%   endfor %}
{% endif %}

{% for number in range(1,student_total|int + 1) %}
[student{{ number }}]
{% for host in ansible_node_facts.instances %}
{% if 'student' ~ number == host.tags.Student %}
{{host.tags.Student}}-ansible ansible_host={{ host.public_ip_address }} ansible_user={{ host.tags.username }}
{% endif %}
{% endfor %}
{% for host in f5_node_facts.instances %}
{% if 'student' ~ number == host.tags.Student %}
{{host.tags.Student}}-f5 ansible_host={{ host.public_ip_address }} ansible_user=admin
{% endif %}
{% endfor %}
{% for host in f5_node1_node_facts.instances %}
{% if 'student' ~ number == host.tags.Student %}
{{host.tags.Student}}-node1 ansible_host={{ host.public_ip_address }} ansible_user={{ host.tags.username }}
{% endif %}
{% endfor %}
{% for host in f5_node2_node_facts.instances %}
{% if 'student' ~ number == host.tags.Student %}
{{host.tags.Student}}-node2 ansible_host={{ host.public_ip_address }} ansible_user={{ host.tags.username }}
{% endif %}
{% endfor %}
{% endfor %}
